<%@page import="com.alibaba.fastjson.JSON"%>
<%@page import="hyl.ext.base.MySession"%>
<%@page import="com.servlet.M2"%>
<%@page language="java" contentType="application/json;charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page	import="hyl.core.db.*,com.servlet.My,hyl.core.info.Content,hyl.core.MyFun"%>

<%
	MySession tk = My.getSession(request,response);
	int role = tk.getRoleid();
	int index = MyFun.str2int(request.getParameter("rs_index"));
	int size = MyFun.str2int(request.getParameter("rs_size"));
	String start = request.getParameter("start");
	String end = request.getParameter("end");
	String ualias = request.getParameter("ualias");
	Content ct = new Content();
	////////////////////////////////dao//////////////////////////////////
	MySqlSelect count = MySqlSelect	.getInstance("SELECT COUNT(1) AS total FROM user a LEFT JOIN user_conf b ON a.id=b.id where 1=1");
	
	String sql = "SELECT (@i:=@i+1)   AS  id,a.uname,a.ualias,a.uphone,a.ctime,a.roleid,a.istate FROM user a LEFT JOIN user_conf b ON a.id=b.id,(SELECT @i := 0) AS it where 1=1 {1} order by a.id desc {2}";

	MySqlSelect2 select = MySqlSelect2.getInstance(sql);
	SelectWhere sw = new SelectWhere();
	sw.add(" and a.roleid=?", M2.ROLE_用户);
	sw.addLike(" and a.ualias like ?", ualias);
	sw.add(" and a.ctime>=?", start);
	sw.add(" and a.ctime<=?", end);
	
	count.addParams(sw);
	select.addParams(1, sw);
	select.fromto(2, index, size);
	ct.setCode(1, "查询成功");
	ct.iniBodys(count.getMap());
	ct.addBodyItem("_rs", select.getList2D());
	out.print(ct.toJsonString());
%>